<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>编辑主题</title>
    <link rel="stylesheet/less" href="../../../static/css/index.less"/>
    <link rel="stylesheet" href="../../../static/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../../static/css/jquery.pagination.css"/>
    <script src="../../../static/js/jquery-1.12.3.js"></script>
    <script src="../../../static/js/ajaxfileupload.js"></script>
    <script src="../../../static/js/less.min.js"></script>
    <script src="../../../static/layui/layui.js"></script>
    <script src="../../../static/layer/layer.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../../static/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../../static/ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="../../../static/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<style>
    .newadd {
        padding: 10px 0;
        display: block;
        text-align: left;
    }

    .newadd label .adtitle {
        display: inline-block;
        width: 6rem;
        text-align: right;
        padding-right: 2%;
    }

    .newadd input {
        padding: 0 10px;
        width: 20%;
        height: 30px;
        line-height: 30px;
        border: 1px solid #dcdcdc;
        border-radius: 5px;
    }

    .newadd select {
        border: 1px solid #dcdcdc;
        border-radius: 5px;
    }

    .button button {
        color: #fff;
        padding: 5px 10px;
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
    }

    .button button a {
        color: #fff;
    }
</style>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    {% include "admin/top.html" %}
    {% include "admin/left.html" %}
    <div class="layui-body">
        <div id="box" class="fl" style="width: 100%">
            <div class="content">
                <h3>编辑主题</h3>
                <div class="newadd">
                    <label for="">
                        <span class="adtitle">主题名称</span>
                        <input id="tname" type="text" value="{{ res.typeName | default('', true) }}">
                    </label>

                    <label for="">
                        <span class="adtitle">主题描述</span>
                        <input type="hidden" id="info" value="{{ res.info | default('', true) }}">
                        <div style="margin-left: 7.8rem"><script id="editor" type="text/plain" style="width:710px;height:150px;"></script></div>
                    </label>

                    <label class="button" style="margin-left: 8rem;">
                        <button id="btn" class="subbtn">提交</button>
                        <button class="subbtn">
                            <a href="javascript:window.history.go(-1)">返回</a>
                        </button>
                    </label>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script>
    var ue = UE.getEditor('editor');
    function getContent() {
        var arr = [];
        arr.push(UE.getEditor('editor').getContent());
        return arr.join("")
    }
    ue.ready(function() {
    ue.setContent($('#info').val());
});
    $("#btn").click(function () {
        var tname = $('#tname').val();
        var info = getContent();
        var sid = "{{ res.sid }}";
        if (tname == ''){
            layer.msg("主题不能为空");
            return false;
        }
        $.ajax({
            url:"/admin/subject_detail_post",
            type:"post",
            data:{
                'tname':tname,
                'info':info,
                'sid':sid
            },
            dataType:"json",
            success:function(msg){
                if (msg.status == 1){
                    layer.msg("操作成功", {time:1200}, function(){
                        location.href = document.referrer;
                    })
                }else {
                    layer.msg("操作失败");
                }
            }
        })

    })
</script>



